Find the smallest multiple of the first N numbers and factorsΒΆ
Find the smallest multiple of the first N numbers.
Also, display the factors.
Test Data:
n = 13
Expected output:
[13, 12, 11, 10, 9, 8, 7]
360360
def smallest_multiple(N):
I = N * 2
factors = [number for number in range(N, 1, -1) if number * 2 > N]
print(factors)
while True:
for a in factors:
if I % a != 0:
I += N
break
if (a == factors[-1] and I % a == 0):
return I
# test
print(smallest_multiple(13))
print()
print(smallest_multiple(11))
Output:
[13, 12, 11, 10, 9, 8, 7]
360360
[11, 10, 9, 8, 7, 6]
27720